<template lang="pug">
FixedScroll
  div(slot="fixed")
    PageHeader(pageTitle="预占用详情")

  FixedTwoTable.table(
      slot="scroll"
      :headList="headList"
      :body="body"
      :isLoading="isLoading"
      :fixedNum="2"
      )
</template>

<script>
import api from "$api"
import util from "$util"

export default {
  data() {
    return {
      isLoading: false,

      headList: [
        { field: "Planno", title: "计划号", checked: true },
        { field: "TimeZone", title: "时区", checked: true },
        // { field: "PartNo", title: "物料号", checked: true },
        { field: "PartName", title: "物料名称", checked: true },
        { field: "PartSupplierNum", title: "供应商", checked: true },
        { field: "OccupancyNum", title: "预占用数", checked: true },
        { field: "BillNo", title: "单号", checked: true },
        { field: "DetailValue", title: "单据状态", checked: true },
        { field: "CreateDate", title: "创建时间", checked: true },
        { field: "UpdateDate", title: "更新时间", checked: true },
        { field: "WmNo", title: "仓库", checked: true },
        { field: "ZoneNo", title: "存储区", checked: true },
      ],
      body: {
        list: [],
      },
    }
  },

  methods: {
    // 获取数据
    async getInfo(query) {
      try {
        let data = await api.StockUsed(query)

        this.transform(data)
        this.body.list = data

      } catch(err) {
        this.$root.error(err)
      } finally {
        this.isLoading = false
      }
    },

    transform(list) {
      for (let item of list) {
        if (item.CreateDate) {
          item.CreateDate = util.transformDate(item.CreateDate)
        }
        if (item.UpdateDate) {
          item.UpdateDate = util.transformDate(item.UpdateDate)
        }
      }
    },
  },

  created() {
    this.getInfo(this.$route.query)
  },
}
</script>

<style lang="stylus" scoped>

.content
  margin: 0.5rem
  text-indent: 2em

</style>
